<?php
/**
 * Created by JetBrains PhpStorm.
 * User: q
 * Date: 14-1-7
 * Time: 下午12:23
 * To change this template use File | Settings | File Templates.
 */
class Teacher_model extends CI_Model{
    function __construct(){
        parent::__construct();
    }

    /**
     *
     */
    function insert($data){
        $this->db->insert('teacher', $data);
    }
    /**
     * 判断该学校是否
     */
    function check_count($id_school){
        $query = $this->db->get_where('school', array('id_school' => $id_school));
        $result = $query->row_array();
        return $result['teacher_count']+1;
    }

    /**
     * 获取该地区学校数量
     */
    function get_count($id_school){
        $check = $this->check_count($id_school);
        $this->plus_one($id_school);
        return $check;
    }

    /**
     * 该地区学校数量加1
     */
    function plus_one($id_school){
        $this->db->where('id_school',$id_school);
        $this->db->set('teacher_count', 'teacher_count+1', FALSE);
        $this->db->update('school');
    }

}